package model;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Service {
	int id;
	int spreadMin;
	List<Integer> dependsOn;
	List<Integer> processes;
	List<Integer> dependedBy;

	public Service() {
		dependsOn = new ArrayList<Integer>();
		processes = new ArrayList<Integer>();
		dependedBy =new ArrayList<Integer>();
	}

	public int getId(){
		return id;
	}
	
	public void setId(int s) {
		this.id = s;
	}

	public void setSpreadMin(int sp) {
		spreadMin = sp;
	}

	public void addDependsOn(int s) {
		dependsOn.add(s);
	}

	public void addDependedBy(int s) {
		dependedBy.add(s);
	}

	public List<Integer> getProcesses() {
		return processes;
	}

	public void addProcess(int p) {
		processes.add(p);
	}

	public int getSpreadMin() {
		return spreadMin;
	}

	public List<Integer> getDependsOn() {
		return dependsOn;
	}

	public List<Integer> getDependedBy() {
		return dependedBy;
	}
	
	public String toString() {
		return String.format("ID=%d %s, SPREADMIN=%d DEPENDSON=%d %s DEPENDEDBY=%d %s", id,
				processes, spreadMin, dependsOn.size(), dependsOn, dependedBy.size(), dependedBy);
	}

	public int getRandomProcess(Random random) {
		return processes.get(random.nextInt(processes.size()));
	}
}
